﻿using Navigant.Model.Custodians;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Navigant.UnitTests
{
    
    
    /// <summary>
    ///This is a test class for CustodianNameTest and is intended
    ///to contain all CustodianNameTest Unit Tests
    ///</summary>
    [TestClass()]
    public class CustodianNameTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        private string GetFullNameWithSpaceSeparator()
        {
            return "Tim D. McCarthy";
        }

        private string GetFullNameWithCommaSeparator()
        {
            return "McCarthy, Tim D.";
            //return "Test, Custodian ";
        }


        /// <summary>
        ///A test for LastName with space separated full name
        ///</summary>
        [TestMethod()]
        public void CustodianNameLastNameWithSpaceSeparatorTest()
        {
            this.LastNameTest(this.GetFullNameWithSpaceSeparator());
        }

        /// <summary>
        ///A test for LastName with comma separated full name
        ///</summary>
        [TestMethod()]
        public void CustodianNameLastNameWithCommaSeparatorTest()
        {
            this.LastNameTest(this.GetFullNameWithCommaSeparator());
        }

        private void LastNameTest(string fullName)
        {
            string expected = "McCarthy";
            CustodianName target = new CustodianName(fullName);
            string actual = target.LastName;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Equals
        ///</summary>
        [TestMethod()]
        public void CustodianNameEqualsTest()
        {
            CustodianName target = new CustodianName(this.GetFullNameWithSpaceSeparator());
            CustodianName custodianName = new CustodianName("Tim McCarthy");
            bool expected = false;
            bool actual = target.Equals(custodianName);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for FullName
        ///</summary>
        [TestMethod()]
        public void CustodianNameFullNameWithCommaSeparatorTest()
        {
            this.FullNameTest(this.GetFullNameWithCommaSeparator());
        }

        /// <summary>
        ///A test for FullName
        ///</summary>
        [TestMethod()]
        public void CustodianNameFullNameWithSpaceSeparatorTest()
        {
            this.FullNameTest(this.GetFullNameWithSpaceSeparator());
        }

        private void FullNameTest(string fullName)
        {
            CustodianName target = new CustodianName(fullName);
            string actual = target.FullName;
            Assert.IsTrue(target.FullName.Contains(","));
        }

        /// <summary>
        ///A test for FirstName
        ///</summary>
        [TestMethod()]
        public void CustodianNameFirstNameWithCommaSeparatorTest()
        {
            this.FirstNameTest(this.GetFullNameWithCommaSeparator());
        }

        /// <summary>
        ///A test for FirstName
        ///</summary>
        [TestMethod()]
        public void CustodianNameFirstNameWithSpaceSeparatorTest()
        {
            this.FirstNameTest(this.GetFullNameWithSpaceSeparator());
        }

        private void FirstNameTest(string fullName)
        {
            string expected = "Tim";
            CustodianName target = new CustodianName(fullName);
            string actual = target.FirstName;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for MiddleName
        ///</summary>
        [TestMethod()]
        public void CustodianNameMiddleNameWithCommaSeparatorTest()
        {
            this.MiddleNameTest(this.GetFullNameWithCommaSeparator());
        }

        /// <summary>
        ///A test for MiddleName
        ///</summary>
        [TestMethod()]
        public void CustodianNameMiddleNameWithSpaceSeparatorTest()
        {
            this.MiddleNameTest(this.GetFullNameWithSpaceSeparator());
        }

        private void MiddleNameTest(string fullName)
        {
            string expected = "D.";
            CustodianName target = new CustodianName(fullName);
            string actual = target.MiddleName;
            Assert.AreEqual(expected, actual);
        }
    }
}
